<template>
  <view class="report-loading">
    <view class="container">
      <WordModule title="白" />

      <view class="calendar">
        <view class="txt1">
          <text></text>
          <text>公历</text>
        </view>
        <view class="date">
          <view class="block"><text>年</text><text>1990</text></view>
          <view class="block"><text>月</text><text>11</text></view>
          <view class="block"><text>日</text><text>2</text></view>
          <view class="block"><text style="font-weight: 600">时</text><text>12</text></view>
        </view>
      </view>

      <view class="content">
        <view v-if="step != 0" class="mask-top"></view>
        <view class="init-loading" ref="scrollToView">
          <view class="sections">
            <view class="section" v-for="(item, index) in contentText" :key="index">
              <view class="title">{{ item.title }}</view>
              <view class="text"> {{ item.text }}</view>
            </view>
          </view>
        </view>

        <view v-if="step != 2" class="mask-btm"></view>
      </view>
    </view>
  </view>
</template>

<script setup>
  import {
    ref,
    nextTick
  } from 'vue';
  import WordModule from '../components/word-module/index.vue';

  const step = ref(0); // 0|开始准备  1|生成过程  2｜完成
  const contentText = ref([{
    title: '生辰排盘中',
    text: '',
  }, ]);
  const scrollToView = ref(null);

  const addContent = async ({
    title,
    text
  }) => {
    // contentRef
    // 填充数据
    contentText.value.push({
      title,
      text
    });
    // 等待页面更新
    await nextTick();
    const view = scrollToView.value.$el;
    view.scrollIntoView({
      behavior: 'smooth'
    });
    view.scrollTop = view.scrollHeight;
  };

  setTimeout(() => {
    step.value = 1;
    addContent({
      title: '地支',
      text: '融合哲学、天文、医学的符号系统。其五行生克与组合规律揭示了自然与人类社会的动态平衡，是理解中华传统文化的重要切入点',
    });
  }, 2000);

  setTimeout(() => {
    addContent({
      title: '支神',
      text: '反映命主与外界（家庭、事业、健康）的互动模式。例如图中地支“戊”与日元相同时为“比肩”，象征同辈助力或自我特质',
    });
  }, 4000);

  setTimeout(() => {
    addContent({
      title: '支神2222',
      text: '反映命主与外界（家庭、事业、健康）的互动模式。例如图中地支“戊”与日元相同时为“比肩”，象征同辈助力或自我特质',
    });
  }, 6000);

  setTimeout(() => {
    step.value = 2
    addContent({
      title: '支神3333',
      text: '反映命主与外界（家庭、事业、健康）的互动模式。例如图中地支“戊”与日元相同时为“比肩”，象征同辈助力或自我特质',
    });
  }, 8000);
</script>

<style lang="less" scoped>
  .report-loading {
    padding: 30px 12px 0 12px;

    .container {
      padding: 20px 18px 0 18px;
      background: #fff;
      border-radius: 12px;

      ::v-deep {
        .word-block {
          margin-top: -20px;
        }
      }
    }

    .calendar {
      padding-bottom: 10px;
      border-bottom: 1px solid #d0d0d0;
      display: flex;
      flex-direction: row;

      font-family: 'PingFang SC';
      font-weight: 400;
      font-size: 12px;
      line-height: 16px;
      color: #222222;

      .txt1 {
        width: 50px;
        font-family: 'PingFang SC';
        font-weight: 600;
        font-size: 12px;
        height: 32px;
        color: #999999;
        margin-right: 30px;
        display: flex;
        flex-direction: column;

        text {
          width: 100%;
          height: 16px;
          text-align: center;
          display: inline-flex;
        }
      }

      .date {
        width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: space-between;

        .block {
          width: 30px;
          display: flex;
          flex-direction: column;

          text {
            width: 100%;
            text-align: center;
          }
        }
      }
    }

    .content {
      position: relative;
      height: 267px;

      .init-loading {
        margin: 20px 0;
        height: 94%;
        overflow-y: auto;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
      }

      .section {
        margin-bottom: 12px;

        .title {
          font-family: 'PingFang SC';
          font-weight: 600;
          font-size: 14px;
          line-height: 22px;
          color: #666666;
          margin-bottom: 4px;
        }

        .text {
          font-size: 12px;
          line-height: 20px;
          font-weight: 400;
          color: #666666;
        }
      }

      .mask-top {
        background: url('images/mask-btm.png') no-repeat;
        background-size: auto 75px;
        height: 75px;
        position: absolute;
        top: -20px;
        left: -18px;
        right: -18px;
        z-index: 2;
        transform: rotateX(182deg);
      }

      .mask-btm {
        background: url('images/mask-btm.png') no-repeat;
        background-size: auto 75px;
        height: 75px;
        position: absolute;
        bottom: 0;
        left: -18px;
        right: -18px;
        z-index: 2;
      }
    }

    &::after {
      content: '';
      background: #e9e8e8;
      position: fixed;
      inset: 0;
      z-index: -1;
    }
  }
</style>